package app.server.project.main.service.db.dao.user;

import app.server.project.main.service.db.entity.user.SolanaInfoEntity;
import app.server.project.main.service.db.mapper.user.SolanaInfoMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;

import java.util.Objects;

@Repository
public class SolanaInfoDao extends ServiceImpl<SolanaInfoMapper, SolanaInfoEntity> {

    @Cacheable(key = "#id", cacheNames = "app.server.project.main.service.db.dao.SolanaInfoDao")
    public SolanaInfoEntity getSolanaInfoData(int id) {
        var data = this.getById(id);
        if (Objects.isNull(data)) {
            //缓存没有,就往库中写入一条数据
            data = SolanaInfoEntity.of(id);
        }
        data.setSynDb(true);
        return data;
    }


}
